package com.liwei.appio;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

//1——方向（参照物内存）【进入内存为输入：input】【内存到其他地方为输出：output】
//2——单位【字节（二进制）input、output】【字符（中文）Reader、Writer】
//3——功能【连接】【过滤】
//java.io为IO流操作的包
public class MyApp1 {
    public static void main(String[] args) {
        String temp="";
        byte[] bytes=new byte[10];
        try {
            FileInputStream fileInputStream =new FileInputStream("D:\\aa.txt");
            //byte[] b字节缓存
            //int off
            //int len
            //return 返回的是目前总数据量，如果没有则为-1

//            //把数据拿到bytes数组,从0开始,拿bytes.length个
//            int read = fileInputStream.read(bytes,0, bytes.length);
//            System.out.println("read:"+read);
//            //把bytes变成字符串拿出来
//            temp=new String(bytes,0,read);
            int read=0;
            StringBuffer stringBuffer=new StringBuffer();
            while ((read = fileInputStream.read(bytes,0, bytes.length))>-1){
                String temp2=new String(bytes,0,read);
                stringBuffer.append(temp2);
            }
            temp=stringBuffer.toString();
            fileInputStream.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println(temp);
    }

}
